{"id":459802,"date":"2025-05-15T15:01:19","date_gmt":"2025-05-15T15:01:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=459802"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=459802","title":{"rendered":"<span>\u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0430 \u043a\u043e\u043b\u0435\u043d\u043a\u0435 \u0447.1<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/hq\/np\/iu\/hqnpiu5t_ixuun9cmlkkgo0eo7i.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/hq\/np\/iu\/hqnpiu5t_ixuun9cmlkkgo0eo7i.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/hq\/np\/iu\/hqnpiu5t_ixuun9cmlkkgo0eo7i.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p> <\/p>\n<h2 id=\"predystoriya\">\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p> <\/p>\n<p>\u0417\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043c\u043d\u0435 \u043a\u0430\u043a-\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u043a\u043e\u043c \u043d\u0430 \u041f\u041b\u0418\u0421, \u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u044f\u0434\u0440\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u041f\u043e\u0438\u0441\u043a \u043d\u0430 opencores \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043f\u043e\u043c\u043e\u0433, x86 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439, ARM \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439, NIOS\u2026 \u043d\u0443, \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043a\u043e\u043c\u0430\u043d\u0434, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043a\u0440\u0438\u0432\u043e, \u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0433\u0434\u0435 \u0431\u0440\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u0412 \u043e\u0431\u0449\u0435\u043c, \u0432\u0441\u0451 \u0431\u044b\u043b\u043e \u0441\u043b\u043e\u0436\u043d\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0438\u0434\u0435\u044e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c.<br \/> \u0421 \u043d\u0435\u0434\u0430\u0432\u043d\u0438\u0445 \u043f\u043e\u0440 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c, \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 RISC-V \u043f\u043e\u0448\u043b\u0430 \u0432 \u043c\u0430\u0441\u0441\u044b.<a name=\"habracut\"><\/a> \u041e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u044f\u0434\u0435\u0440 \u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0435, \u043a\u0438\u0442\u0430\u0439\u0446\u044b \u043a\u043b\u0435\u043f\u0430\u044e\u0442 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b, \u0438 ESP, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 RISC-V, \u0440\u0443\u0441\u0441\u043a\u0438\u0435 \u0442\u043e\u0436\u0435 \u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438. \u0421 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0434\u043e\u043b\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 x86 \u0438 ARM \u043f\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u0441\u044f \u0441 \u0440\u044b\u043d\u043a\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0435.<br \/> \u0422\u0430\u043a \u0432\u043e\u0442, \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a DIY. \u0410\u0432\u0442\u043e\u0440 \u044f\u0434\u0440\u0430 DarkRiscV \u043f\u043e\u0445\u0432\u0430\u0441\u0442\u0430\u043b\u0441\u044f, \u0447\u0442\u043e \u0441\u043e\u0431\u0440\u0430\u043b \u044f\u0434\u0440\u043e \u0437\u0430 \u043e\u0434\u0438\u043d \u0434\u0435\u043d\u044c. \u0423 \u043c\u0435\u043d\u044f \u0437\u0430 \u043f\u043b\u0435\u0447\u0430\u043c\u0438 \u043e\u043f\u044b\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u0438\u043a\u0440\u043e\u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u0438\u043a\u0438 \u043d\u0435 \u0431\u044b\u043b\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0433\u0434\u0430 \u044f\u0434\u0440\u043e \u0442\u0430\u043a \u0436\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0437\u0430 \u043e\u0434\u0438\u043d \u0434\u0435\u043d\u044c, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c: &#171;\u041b\u043e\u043b, \u0438 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442&#187;.<\/p>\n<p> <\/p>\n<h2 id=\"dokumentaciya\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/h2>\n<p> <\/p>\n<p>\u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 <a href=\"https:\/\/xpack-dev-tools.github.io\/\" rel=\"nofollow noopener noreferrer\">gcc risc-v<\/a>, \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440 <a href=\"https:\/\/bleyer.org\/icarus\/\" rel=\"nofollow noopener noreferrer\">icarus verilog<\/a> \u0438 \u0431\u043b\u043e\u043a\u043d\u043e\u0442. \u041e\u0431\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u043c\u0438, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/lf-riscv.atlassian.net\/wiki\/spaces\/HOME\/pages\/16154769\/RISC-V+Technical+Specifications\" rel=\"nofollow noopener noreferrer\">RISC-V Instruction Set Manual<\/a>, \u043d\u043e \u0432 \u043d\u0435\u0439 \u043a\u043e\u0434\u044b \u043a\u043e\u043c\u0430\u043d\u0434 \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0437\u0430\u043a\u043e\u043f\u0430\u043d\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0448\u043b\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0433\u043e <a href=\"https:\/\/www.cs.sfu.ca\/~ashriram\/Courses\/CS295\/assets\/notebooks\/RISCV\/RISCV_CARD.pdf\" rel=\"nofollow noopener noreferrer\">\u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434 \u0441 \u043e\u043f\u043a\u043e\u0434\u0430\u043c\u0438<\/a>. \u042d\u0442\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u041f\u0435\u0440\u0432\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0432 \u043a\u0430\u043a\u043e\u043c \u043c\u0435\u0441\u0442\u0435 32-\u0431\u0438\u0442\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043b\u0435\u0436\u0430\u0442: <\/p>\n<p> <\/p>\n<ul>\n<li>\u043a\u043e\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u2014 <strong>opcode<\/strong><\/li>\n<li>\u043d\u043e\u043c\u0435\u0440 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u2014 <strong>rd<\/strong><\/li>\n<li>\u043d\u043e\u043c\u0435\u0440\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u2014 <strong>rs1<\/strong> \u0438 <strong>rs2<\/strong><\/li>\n<li>\u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 <strong>func3<\/strong> \u0438 <strong>funct7<\/strong><\/li>\n<li>\u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u2014 <strong>imm<\/strong><\/li>\n<\/ul>\n<p> <\/p>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0432 6 \u0433\u0440\u0443\u043f\u043f (<strong>R<\/strong>, <strong>I<\/strong>, <strong>S<\/strong>, <strong>B<\/strong>, <strong>U<\/strong>, <strong>J<\/strong>), \u0432\u044b\u0431\u043e\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u044d\u0442\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b.<\/p>\n<p> <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/o8\/gb\/mm\/o8gbmmshk7vv-hi1xkzv2kkuq3o.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/o8\/gb\/mm\/o8gbmmshk7vv-hi1xkzv2kkuq3o.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/o8\/gb\/mm\/o8gbmmshk7vv-hi1xkzv2kkuq3o.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p> <\/p>\n<p>\u0412\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u0440\u043e\u043c\u0435 <strong>immediate<\/strong> \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0412 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\u0445 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e <strong>immediate<\/strong> \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0431\u0438\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u043b\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u0430\u0445 \u043a\u043e\u043c\u0430\u043d\u0434. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043f\u0440\u0438 \u0441\u0438\u043d\u0442\u0435\u0437\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0436\u0435\u043b\u0435\u0437\u043e \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u043b\u043e\u0433\u0438\u043a\u0438, \u0445\u043e\u0442\u044f \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432 \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<p> <\/p>\n<h2 id=\"kod\">\u041a\u043e\u0434<\/h2>\n<p> <\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u043c\u0430\u0440\u043a\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u043e\u0440\u0447\u0430\u0442 \u0438\u0437 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">module RiscVCore (     input clock,     input reset,      output [31:0] instruction_address, \/\/\u043e\u0442\u043a\u0443\u0434\u0430 \u0447\u0438\u0442\u0430\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e     input  [31:0] instruction_data, \/\/\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f      output [31:0] data_address, \/\/\u0430\u0434\u0440\u0435\u0441 \u043d\u0430 \u0448\u0438\u043d\u0435 \u0434\u0430\u043d\u043d\u044b\u0445     output [1:0]  data_width, \/\/\u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 (8, 16, 32 \u0431\u0438\u0442\u0430)     input  [31:0] data_in, \/\/\u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438     output [31:0] data_out, \/\/\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435     output        data_read, \/\/\u0434\u043e\u043b\u0436\u043d\u0430 \u043b\u0438 \u043f\u0430\u043c\u044f\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u043c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c     output        data_write \/\/\u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0441\u0435\u0431\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c );<\/code><\/pre>\n<p> <\/p>\n<p>\u0418 \u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u0430\u044f 32-\u0431\u0438\u0442\u043d\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f, \u0438 \u043d\u0430\u043c \u0435\u0451 \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437 \u0448\u0438\u043d\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e wire [31:0] instruction = instruction_data;  \/\/\u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u0434 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 wire[6:0] op_code = instruction[6:0]; \/\/\u043a\u043e\u0434 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 wire[4:0] op_rd = instruction[11:7]; \/\/\u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 wire[2:0] op_funct3 = instruction[14:12]; \/\/\u043f\u043e\u0434\u043a\u043e\u0434 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 wire[4:0] op_rs1 = instruction[19:15]; \/\/\u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043e\u043f\u0435\u0440\u0430\u043d\u0434 1 wire[4:0] op_rs2 = instruction[24:20]; \/\/\u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043e\u043f\u0435\u0440\u0430\u043d\u0434 2 wire[6:0] op_funct7 = instruction[31:25]; wire[31:0] op_immediate_i = {{20{instruction[31]}}, instruction[31:20]}; \/\/\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 I-\u0442\u0438\u043f\u0430 wire[31:0] op_immediate_s = {{20{instruction[31]}}, instruction[31:25], instruction[11:7]}; \/\/\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 S-\u0442\u0438\u043f\u0430 wire[31:0] op_immediate_u = {instruction[31:12], 12'b0}; wire[31:0] op_immediate_b = {{20{instruction[31]}}, instruction[7],                               instruction[30:25], instruction[11:8], 1'b0}; wire[31:0] op_immediate_j = {{12{instruction[31]}}, instruction[19:12],                               instruction[20], instruction[30:21], 1'b0};<\/code><\/pre>\n<p> <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0441\u0441\u0447\u0451\u0442\u044b \u2014 \u044d\u0442\u043e \u043b\u0438\u0448\u043d\u044f\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0438 \u043d\u0430\u0434\u043e \u0431\u044b \u0437\u0430\u0441\u0443\u043d\u0443\u0442\u044c \u043f\u043e\u0434 if, \u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0436\u0435\u043b\u0435\u0437\u043e, \u0438 \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u043b\u043e\u0433\u0438\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c, \u0442\u043e \u043c\u0435\u0441\u0442\u043e \u043e\u043d\u0430 \u0437\u0430\u0439\u043c\u0451\u0442 \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<p> <\/p>\n<p>\u0421 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c \u043a\u043e\u043c\u0430\u043d\u0434 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u043c. RV32I \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0435\u0433\u043e \u0438 \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c. \u0421\u043e\u0441\u0442\u043e\u0438\u0442 \u043e\u043d \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434: \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 (<strong>l<\/strong>), \u0437\u0430\u043f\u0438\u0441\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c (<strong>s<\/strong>), \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441 \u0434\u0432\u0443\u043c\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u043c\u0438, \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043c \u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (<strong>lui<\/strong>), \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043b\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 (<strong>auipc<\/strong>), \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 (<strong>b<\/strong>), \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 (<strong>jal<\/strong>), \u0434\u0430\u043b\u044c\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 (<strong>jalr<\/strong>). \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440, \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0438 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u044d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0443 description \u0432 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u0412 \u043d\u0430\u0431\u043e\u0440\u0435 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043f\u0430\u0440\u0430 \u043a\u043e\u043c\u0430\u043d\u0434 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u043d\u0438\u0445.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/ \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 rv32i `define opcode_load        7'b00000_11 \/\/l**   rd,  rs1,imm     rd = m[rs1 + imm]; load bytes `define opcode_store       7'b01000_11 \/\/s**   rs1, rs2,imm     m[rs1 + imm] = rs2; store bytes `define opcode_alu         7'b01100_11 \/\/***   rd, rs1, rs2     rd = rs1 x rs2; arithmetical `define opcode_alu_imm     7'b00100_11 \/\/***   rd, rs1, imm     rd = rs1 x imm; arithmetical with immediate `define opcode_load_upper  7'b01101_11 \/\/lui   rd, imm          rd = imm &lt;&lt; 12; load upper imm `define opcode_add_upper   7'b00101_11 \/\/auipc rd, imm          rd = pc + (imm &lt;&lt; 12); add upper imm to PC `define opcode_branch      7'b11000_11 \/\/b**   rs1, rs2, imm   if () pc += imm `define opcode_jal         7'b11011_11 \/\/jal   rd,imm   jump and link, rd = PC+4; PC += imm `define opcode_jalr        7'b11001_11 \/\/jalr  rd,rs1,imm   jump and link reg, rd = PC+4; PC = rs1 + imm<\/code><\/pre>\n<p> <\/p>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u043b\u0430\u0433, \u043e\u043d\u0430 \u044d\u0442\u043e \u0438\u043b\u0438 \u043d\u0435 \u043e\u043d\u0430. \u0414\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0444\u043b\u0430\u0433\u0430\u043c\u0438.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e wire is_op_load = op_code == `opcode_load; wire is_op_store = op_code == `opcode_store; wire is_op_alu = op_code == `opcode_alu; wire is_op_alu_imm = op_code == `opcode_alu_imm; wire is_op_load_upper = op_code == `opcode_load_upper; wire is_op_add_upper = op_code == `opcode_add_upper; wire is_op_branch = op_code == `opcode_branch; wire is_op_jal = op_code == `opcode_jal; wire is_op_jalr = op_code == `opcode_jalr;<\/code><\/pre>\n<p> <\/p>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e, \u043d\u0430\u043c \u043f\u043e\u043a\u0430 \u0431\u0435\u0437 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u043a\u0430\u043a\u043e\u0439 \u043e\u043f\u043a\u043e\u0434 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b. \u041e\u0434\u043d\u0430\u043a\u043e \u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0438\u0448\u0443\u0442 \u0442\u0443\u0434\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043a\u043e\u0434\u0435 \u043a\u043e\u043c\u0430\u043d\u0434 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u0435\u043c \u0432 \u043e\u0434\u0438\u043d, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043e\u043f\u043a\u043e\u0434\u0443.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0438\u0437 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \/\/wire [31:0] reg_d = regs[op_rd]; wire [31:0] reg_s1 = regs[op_rs1]; wire [31:0] reg_s2 = regs[op_rs2]; wire signed [31:0] reg_s1_signed = reg_s1; wire signed [31:0] reg_s2_signed = reg_s2;<\/code><\/pre>\n<p> <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u043f\u043a\u043e\u0434\u0430.<\/p>\n<p> <\/p>\n<h4 id=\"load\">load<\/h4>\n<p> <\/p>\n<p>\u0427\u0442\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 <strong>funct3<\/strong>. \u0421\u043d\u0430\u0440\u0443\u0436\u0438, \u0432 \u0448\u0438\u043d\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0434\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e\u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u0441\u0434\u0432\u0438\u0433, \u0430 \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e 32-\u0445 \u0431\u0438\u0442. \u041a\u0441\u0442\u0430\u0442\u0438 \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0430 \u0432\u043e\u0437\u043d\u044e \u0441 \u0448\u0438\u043d\u043e\u0439 \u0442\u043e\u0436\u0435 \u0443\u0448\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 (lb, lh, lw, lbu, lhu), I-\u0442\u0438\u043f assign data_read = is_op_load; wire load_signed = ~op_funct3[2]; wire [31:0] load_data = op_funct3[1:0] == 0 ? {{24{load_signed &amp; data_in[7]}}, data_in[7:0]} : \/\/0-byte                         op_funct3[1:0] == 1 ? {{16{load_signed &amp; data_in[15]}}, data_in[15:0]} : \/\/1-half                         data_in; \/\/2-word<\/code><\/pre>\n<p> <\/p>\n<h4 id=\"store\">store<\/h4>\n<p> <\/p>\n<p>\u0421 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0435\u0449\u0451 \u043f\u0440\u043e\u0449\u0435, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440, \u0438 \u043f\u0443\u0441\u0442\u044c \u0448\u0438\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0430\u043c\u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f. \u0410 \u0435\u0449\u0451 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0434\u043e \u043f\u0438\u0441\u0430\u0442\u044c, \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u043c \u0432\u044b\u0445\u043e\u0434\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u0444\u043e\u043d\u0438\u043b \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437 \u043d\u0430\u0440\u0443\u0436\u0443 \u0438 \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u043b \u044d\u043d\u0435\u0440\u0433\u0438\u044e. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0437\u0430 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0443\u043c\u0435\u0435\u0442 \u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0432\u0443\u0445 \u0448\u0438\u043d \u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u0437\u0430\u043f\u0438\u0441\u044c \u043f\u0430\u043c\u044f\u0442\u0438 (sb, sh, sw), S-\u0442\u0438\u043f assign data_write = is_op_store; assign data_out = is_op_store ? reg_s2 : 0;  \/\/\u043e\u0431\u0449\u0435\u0435 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 wire [11:0] address_imm = data_read ? op_immediate_i : data_write ? op_immediate_s : 0; assign data_address = (is_op_load || is_op_store) ? reg_s1 + address_imm : 0; assign data_width = (is_op_load || is_op_store) ? op_funct3[1:0] : 'b11; \/\/0-byte, 1-half, 2-word<\/code><\/pre>\n<p> <\/p>\n<h4 id=\"alu\">alu<\/h4>\n<p> <\/p>\n<p>\u0410\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0435\u043b\u0430\u044e\u0442\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a, \u043d\u043e \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0431\u044b \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043a\u043e\u0434 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 (add, sub, xor, or, and, sll, srl, sra, slt, sltu) wire [31:0] alu_operand2 = is_op_alu ? reg_s2 : is_op_alu_imm ? op_immediate_i : 0; wire [31:0] alu_result = op_funct3 == 0 ? (is_op_alu &amp;&amp; op_funct7[5] ? reg_s1 - alu_operand2 : reg_s1 + alu_operand2) :                          op_funct3 == 4 ? reg_s1 ^ alu_operand2 :                          op_funct3 == 6 ? reg_s1 | alu_operand2 :                          op_funct3 == 7 ? reg_s1 &amp; alu_operand2 :                          op_funct3 == 1 ? reg_s1 &lt;&lt; alu_operand2[4:0] :                          op_funct3 == 5 ? (op_funct7[5] ? reg_s1_signed &gt;&gt;&gt; alu_operand2[4:0] : reg_s1 &gt;&gt; alu_operand2[4:0]) :                          op_funct3 == 2 ? reg_s1_signed &lt; $signed(alu_operand2) :                          op_funct3 == 3 ? reg_s1 &lt; alu_operand2 :                          0; \/\/\u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/code><\/pre>\n<p> <\/p>\n<h4 id=\"lui-i-auipc\">lui \u0438 auipc<\/h4>\n<p> <\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 <strong>lui<\/strong> \u0438 <strong>auipc<\/strong>.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 upper immediate wire [31:0] load_upper_result = op_immediate_u; \/\/lui wire [31:0] add_upper_result = pc + op_immediate_u; \/\/auipc<\/code><\/pre>\n<p> <\/p>\n<h4 id=\"branch\">branch<\/h4>\n<p> <\/p>\n<p>\u0422\u0430\u043a\u0430\u044f \u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432. \u0422\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u0430\u0436\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442: \u043a\u0440\u043e\u043c\u0435 <strong>rd<\/strong> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438 <strong>pc<\/strong>.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439 wire [31:0] branch_pc = pc + op_immediate_b; wire branch_fired = op_funct3 == 0 &amp;&amp; reg_s1 == reg_s2 || \/\/beq                     op_funct3 == 1 &amp;&amp; reg_s1 != reg_s2 || \/\/bne                     op_funct3 == 4 &amp;&amp; reg_s1_signed &lt;  reg_s2_signed || \/\/blt                     op_funct3 == 5 &amp;&amp; reg_s1_signed &gt;= reg_s2_signed || \/\/bge                     op_funct3 == 6 &amp;&amp; reg_s1 &lt;  reg_s2 || \/\/bltu                     op_funct3 == 7 &amp;&amp; reg_s1 &gt;= reg_s2; \/\/bgeu<\/code><\/pre>\n<p> <\/p>\n<h4 id=\"jal-jalr\">jal, jalr<\/h4>\n<p> <\/p>\n<p>\u0415\u0449\u0451 \u0434\u0432\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432, \u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435 <strong>pc<\/strong> \u2014 \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b: \u043d\u0430 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e <strong>pc<\/strong>.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0438 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b (jal, jalr) wire [31:0] jal_result = pc + 4; wire [31:0] jal_pc = pc + op_immediate_j; wire [31:0] jalr_pc = reg_s1 + op_immediate_i; \/\/\u0437\u0434\u0435\u0441\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e I-\u0442\u0438\u043f<\/code><\/pre>\n<p> <\/p>\n<h4 id=\"zapis-v-rd-i-pc\">\u0417\u0430\u043f\u0438\u0441\u044c \u0432 rd \u0438 pc<\/h4>\n<p> <\/p>\n<p>\u041d\u0443 \u043a\u0430\u043a \u0431\u044b \u0438 \u0432\u0441\u0451, \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043d\u044b, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0445 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 integer i; always@(posedge clock or posedge reset) begin     if (reset == 1) begin         for (i = 0; i &lt; `REG_COUNT; i=i+1) regs[i] = 0; \/\/\u042d\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u044a\u0435\u0434\u0430\u0435\u0442 LE         pc = 0;     end else begin         regs[op_rd] &lt;= op_rd == 0 ? 0 : \/\/x0 = 0                        is_op_load ? load_data :                        is_op_alu || is_op_alu_imm ? alu_result :                        is_op_load_upper ? load_upper_result :                        is_op_add_upper ? add_upper_result :                        is_op_jal || is_op_jalr ? jal_result :                        regs[op_rd];          pc &lt;= (is_op_branch &amp;&amp; branch_fired) ? branch_pc :               is_op_jal ? jal_pc :               is_op_jalr ? jalr_pc :               pc + 4;     end end<\/code><\/pre>\n<p> <\/p>\n<p>\u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, <strong>pc<\/strong> \u043f\u0440\u0438 \u0441\u0431\u0440\u043e\u0441\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435, \u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0438 \u0442\u0430\u043a \u0441\u043e\u0439\u0434\u0451\u0442. \u0421\u0443\u043c\u043c\u0430\u0440\u043d\u043e \u043a\u043e\u0434 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0437\u0430\u043d\u044f\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 150 \u0441\u0442\u0440\u043e\u043a.<br \/> \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong>pc + op_immediate<\/strong> \u0438 <strong>reg_s1 + op_immediate<\/strong> \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e 3 \u0440\u0430\u0437\u0430, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 <strong>rd<\/strong> \u0438 <strong>pc<\/strong>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0442 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u0434\u0435\u0440\u0436\u0430\u0442\u044c <strong>immediate<\/strong> \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u044c\u043d\u043e, \u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043e\u0434\u043d\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.<\/p>\n<p> <\/p>\n<pre><code class=\"vhdl\">\/\/\u043a\u0430\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 wire type_r = is_op_alu; wire type_i = is_op_alu_imm || is_op_load || is_op_jalr; wire type_s = is_op_store; wire type_b = is_op_branch; wire type_u = is_op_load_upper || is_op_add_upper; wire type_j = is_op_jal;  \/\/\u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b wire [31:0] immediate = type_i ? op_immediate_i :                 type_s ? op_immediate_s :                 type_b ? op_immediate_b :                 type_j ? op_immediate_j :                 type_u ? op_immediate_u :                 0;<\/code><\/pre>\n<p> <\/p>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c.<\/p>\n<p> <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">core.v<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"vhdl\">\/\/ \u044f\u0434\u0440\u043e risc-v \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430  \/\/ \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 rv32i `define opcode_load        7'b00000_11 \/\/I \/\/l**   rd,  rs1,imm     rd = m[rs1 + imm]; load bytes `define opcode_store       7'b01000_11 \/\/S \/\/s**   rs1, rs2,imm     m[rs1 + imm] = rs2; store bytes `define opcode_alu         7'b01100_11 \/\/R \/\/***   rd, rs1, rs2     rd = rs1 x rs2; arithmetical `define opcode_alu_imm     7'b00100_11 \/\/I \/\/***   rd, rs1, imm     rd = rs1 x imm; arithmetical with immediate `define opcode_load_upper  7'b01101_11 \/\/U \/\/lui   rd, imm          rd = imm &lt;&lt; 12; load upper imm `define opcode_add_upper   7'b00101_11 \/\/U \/\/auipc rd, imm          rd = pc + (imm &lt;&lt; 12); add upper imm to PC `define opcode_branch      7'b11000_11 \/\/B \/\/b**   rs1, rs2, imm    if (rs1 x rs2) pc += imm `define opcode_jal         7'b11011_11 \/\/J \/\/jal   rd,imm   jump and link, rd = PC+4; PC += imm `define opcode_jalr        7'b11001_11 \/\/I \/\/jalr  rd,rs1,imm   jump and link reg, rd = PC+4; PC = rs1 + imm  `ifdef __RV32E__     `define REG_COUNT 16 \/\/\u0434\u043b\u044f embedded \u0447\u0438\u0441\u043b\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043c\u0435\u043d\u044c\u0448\u0435 `else     `define REG_COUNT 32 `endif  module RiscVCore (     input clock,     input reset,     input irq,      output [31:0] instruction_address,     input  [31:0] instruction_data,      output [31:0] data_address,     output [1:0]  data_width,     input  [31:0] data_in,     output [31:0] data_out,     output        data_read,     output        data_write );  \/\/\u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 reg [31:0] regs [0:`REG_COUNT-1]; \/\/x0-x31 reg [31:0] pc;  \/\/\u0434\u043e\u0441\u0442\u0430\u0451\u043c \u0438\u0437 pc \u0430\u0434\u0440\u0435\u0441 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0438 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u043c \u0432 \u0448\u0438\u043d\u0443 assign instruction_address = pc;  \/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437 \u0448\u0438\u043d\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e wire [31:0] instruction = instruction_data;  \/\/\u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u0434 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 wire[6:0] op_code = instruction[6:0]; \/\/\u043a\u043e\u0434 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 wire[4:0] op_rd = instruction[11:7]; \/\/\u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 wire[2:0] op_funct3 = instruction[14:12]; \/\/\u043f\u043e\u0434\u043a\u043e\u0434 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 wire[4:0] op_rs1 = instruction[19:15]; \/\/\u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043e\u043f\u0435\u0440\u0430\u043d\u0434 1 wire[4:0] op_rs2 = instruction[24:20]; \/\/\u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043e\u043f\u0435\u0440\u0430\u043d\u0434 2 wire[6:0] op_funct7 = instruction[31:25]; wire[31:0] op_immediate_i = {{20{instruction[31]}}, instruction[31:20]}; \/\/\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 I-\u0442\u0438\u043f\u0430 wire[31:0] op_immediate_s = {{20{instruction[31]}}, instruction[31:25], instruction[11:7]}; \/\/\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 S-\u0442\u0438\u043f\u0430 wire[31:0] op_immediate_u = {instruction[31:12], 12'b0}; wire[31:0] op_immediate_b = {{20{instruction[31]}}, instruction[7],                               instruction[30:25], instruction[11:8], 1'b0}; wire[31:0] op_immediate_j = {{12{instruction[31]}}, instruction[19:12],                               instruction[20], instruction[30:21], 1'b0}; \/\/\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e wire is_op_load = op_code == `opcode_load; wire is_op_store = op_code == `opcode_store; wire is_op_alu = op_code == `opcode_alu; wire is_op_alu_imm = op_code == `opcode_alu_imm; wire is_op_load_upper = op_code == `opcode_load_upper; wire is_op_add_upper = op_code == `opcode_add_upper; wire is_op_branch = op_code == `opcode_branch; wire is_op_jal = op_code == `opcode_jal; wire is_op_jalr = op_code == `opcode_jalr;  wire error_opcode = !(is_op_load || is_op_store ||                     is_op_alu || is_op_alu_imm ||                     is_op_load_upper || is_op_add_upper ||                     is_op_branch || is_op_jal || is_op_jalr);  \/\/\u043a\u0430\u043a\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 wire type_r = is_op_alu; wire type_i = is_op_alu_imm || is_op_load || is_op_jalr; wire type_s = is_op_store; wire type_b = is_op_branch; wire type_u = is_op_load_upper || is_op_add_upper; wire type_j = is_op_jal;  \/\/\u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b wire [31:0] immediate = type_i ? op_immediate_i :                 type_s ? op_immediate_s :                 type_b ? op_immediate_b :                 type_j ? op_immediate_j :                 type_u ? op_immediate_u :                 0;  \/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u044b \u0438\u0437 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \/\/wire [31:0] reg_d = regs[op_rd]; wire [31:0] reg_s1 = regs[op_rs1]; wire [31:0] reg_s2 = regs[op_rs2]; wire signed [31:0] reg_s1_signed = reg_s1; wire signed [31:0] reg_s2_signed = reg_s2;  \/\/\u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 (lb, lh, lw, lbu, lhu), I-\u0442\u0438\u043f assign data_read = is_op_load; wire load_signed = ~op_funct3[2]; wire [31:0] rd_load = op_funct3[1:0] == 0 ? {{24{load_signed &amp; data_in[7]}}, data_in[7:0]} : \/\/0-byte                       op_funct3[1:0] == 1 ? {{16{load_signed &amp; data_in[15]}}, data_in[15:0]} : \/\/1-half                       data_in; \/\/2-word  \/\/\u0437\u0430\u043f\u0438\u0441\u044c \u043f\u0430\u043c\u044f\u0442\u0438 (sb, sh, sw), S-\u0442\u0438\u043f assign data_write = is_op_store; assign data_out = is_op_store ? reg_s2 : 0;  \/\/\u043e\u0431\u0449\u0435\u0435 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 assign data_address = (is_op_load || is_op_store) ? reg_s1 + immediate : 0; assign data_width = (is_op_load || is_op_store) ? op_funct3[1:0] : 'b11; \/\/0-byte, 1-half, 2-word  \/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 (add, sub, xor, or, and, sll, srl, sra, slt, sltu) wire [31:0] alu_operand2 = is_op_alu ? reg_s2 : is_op_alu_imm ? immediate : 0; wire [31:0] rd_alu = op_funct3 == 0 ? (is_op_alu &amp;&amp; op_funct7[5] ? reg_s1 - alu_operand2 : reg_s1 + alu_operand2) :                      op_funct3 == 4 ? reg_s1 ^ alu_operand2 :                      op_funct3 == 6 ? reg_s1 | alu_operand2 :                      op_funct3 == 7 ? reg_s1 &amp; alu_operand2 :                      op_funct3 == 1 ? reg_s1 &lt;&lt; alu_operand2[4:0] :                      op_funct3 == 5 ? (op_funct7[5] ? reg_s1_signed &gt;&gt;&gt; alu_operand2[4:0] : reg_s1 &gt;&gt; alu_operand2[4:0]) :                      op_funct3 == 2 ? reg_s1_signed &lt; $signed(alu_operand2) :                      op_funct3 == 3 ? reg_s1 &lt; alu_operand2 : \/\/TODO \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 imm \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c                      0; \/\/\u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442  \/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 upper immediate wire [31:0] rd_load_upper = immediate; \/\/lui wire [31:0] rd_add_upper = pc + immediate; \/\/auipc  \/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439 wire [31:0] pc_branch = pc + immediate; wire branch_fired = op_funct3 == 0 &amp;&amp; reg_s1 == reg_s2 || \/\/beq                     op_funct3 == 1 &amp;&amp; reg_s1 != reg_s2 || \/\/bne                     op_funct3 == 4 &amp;&amp; reg_s1_signed &lt;  reg_s2_signed || \/\/blt                     op_funct3 == 5 &amp;&amp; reg_s1_signed &gt;= reg_s2_signed || \/\/bge                     op_funct3 == 6 &amp;&amp; reg_s1 &lt;  reg_s2 || \/\/bltu                     op_funct3 == 7 &amp;&amp; reg_s1 &gt;= reg_s2; \/\/bgeu  \/\/\u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0438 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b (jal, jalr) wire [31:0] rd_jal = pc + 4; wire [31:0] pc_jal = pc + immediate; wire [31:0] pc_jalr = reg_s1 + immediate;  \/\/\u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 integer i; always@(posedge clock or posedge reset) begin     if (reset == 1) begin         for (i = 0; i &lt; `REG_COUNT; i=i+1) regs[i] = 0;         pc = 0;     end else begin         regs[op_rd] &lt;= op_rd == 0 ? 0 : \/\/x0 = 0                        is_op_load ? rd_load :                        is_op_alu || is_op_alu_imm ? rd_alu :                        is_op_load_upper ? rd_load_upper :                        is_op_add_upper ? rd_add_upper :                        is_op_jal || is_op_jalr ? rd_jal :                        regs[op_rd];          pc &lt;= (is_op_branch &amp;&amp; branch_fired) ? pc_branch :               is_op_jal ? pc_jal :               is_op_jalr ? pc_jalr :               pc + 4;     end end endmodule<\/code><\/pre>\n<\/div><\/div>\n<p> <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044f\u0434\u0440\u043e \u043d\u0430 \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d verilog \u0444\u0430\u0439\u043b \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435: \u0442\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0448\u0438\u043d\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0435\u0449\u0451 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0434\u043b\u044f \u0432\u044b\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c. \u041d\u043e \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 <strong>CoreMark<\/strong>.<\/p>\n<p> <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/kn\/lb\/ju\/knlbjuxbvx6tbs8rw-693zu9huo.png\" alt=\"image\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/kn\/lb\/ju\/knlbjuxbvx6tbs8rw-693zu9huo.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/kn\/lb\/ju\/knlbjuxbvx6tbs8rw-693zu9huo.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p> <\/p>\n<p>\u0422\u0430\u0439\u043c\u0435\u0440 \u0434\u0435\u043b\u0438\u0442 \u0442\u0430\u043a\u0442\u043e\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043d\u0430 100, \u0442\u0435\u0441\u0442 \u0434\u0435\u043b\u0438\u0442 \u0435\u0449\u0451 \u043d\u0430 100. \u041e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434 \u0442\u0435\u0441\u0442\u0430 \u0432 \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043b\u0442\u043e\u0440\u044b \u043c\u0438\u043d\u0443\u0442\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043a \u043c\u0430\u043b\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432. \u0420\u0435\u0439\u0442\u0438\u043d\u0433 <a href=\"https:\/\/github.com\/eembc\/coremark\/issues\/41\" rel=\"nofollow noopener noreferrer\">\u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f<\/a> \u043a\u0430\u043a \u0447\u0438\u0441\u043b\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439\/\u0447\u0438\u0441\u043b\u043e \u043a\u043b\u043e\u043a\u043e\u0432 * \u043c\u0435\u0433\u0430\u0433\u0435\u0440\u0446. 1 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \/ (7737 ticks * 100 \u043a\u043b\u043e\u043a\u043e\u0432) * 1\u041c \u0434\u0430\u0451\u0442 1.29 CM, \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u043b\u0430\u0431\u044b\u0445 \u044f\u0434\u0435\u0440 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0434\u043e 2.7, \u0430 \u044d\u0442\u043e \u0443\u0436\u0435 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0435 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b. \u041c\u043e\u0436\u043d\u043e <a href=\"https:\/\/www.eembc.org\/coremark\/scores.php\" rel=\"nofollow noopener noreferrer\">\u0437\u0434\u0435\u0441\u044c<\/a> \u043f\u043e\u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c.<\/p>\n<p> <\/p>\n<p>\u042f\u0434\u0440\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435, gtk wave \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u043d\u043e \u0434\u043b\u044f \u0441\u0438\u043d\u0442\u0435\u0437\u0430 \u043d\u0430 \u041f\u041b\u0418\u0421 \u043d\u0430\u0434\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u0438 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f\u0445, \u043f\u0440\u0438\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 (\u0443 \u043c\u0435\u043d\u044f \u0437\u0430\u043d\u044f\u043b\u043e \u043d\u0435\u0434\u0435\u043b\u044e, \u043c\u043e\u0436\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0451 \u0441\u0442\u0430\u0442\u044c\u044f). \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0430\u0434\u0430\u0435\u0442 \u0434\u043e 2.3, \u0445\u043e\u0442\u044f \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u0440\u0443\u0442\u0438\u0442\u044c.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/909700\/\"> https:\/\/habr.com\/ru\/articles\/909700\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/hq\/np\/iu\/hqnpiu5t_ixuun9cmlkkgo0eo7i.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/hq\/np\/iu\/hqnpiu5t_ixuun9cmlkkgo0eo7i.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/hq\/np\/iu\/hqnpiu5t_ixuun9cmlkkgo0eo7i.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p> <\/p>\n<h2 id=\"predystoriya\">\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p> <\/p>\n<p>\u0417\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043c\u043d\u0435 \u043a\u0430\u043a-\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u043a\u043e\u043c \u043d\u0430 \u041f\u041b\u0418\u0421, \u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u044f\u0434\u0440\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u041f\u043e\u0438\u0441\u043a \u043d\u0430 opencores \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043f\u043e\u043c\u043e\u0433, x86 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439, ARM \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439, NIOS\u2026 \u043d\u0443, \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043a\u043e\u043c\u0430\u043d\u0434, \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043a\u0440\u0438\u0432\u043e, \u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0433\u0434\u0435 \u0431\u0440\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u0412 \u043e\u0431\u0449\u0435\u043c, \u0432\u0441\u0451 \u0431\u044b\u043b\u043e \u0441\u043b\u043e\u0436\u043d\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0438\u0434\u0435\u044e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c.<br \/> \u0421 \u043d\u0435\u0434\u0430\u0432\u043d\u0438\u0445 \u043f\u043e\u0440 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c, \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 RISC-V \u043f\u043e\u0448\u043b\u0430 \u0432 \u043c\u0430\u0441\u0441\u044b.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-459802","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=459802"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459802\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=459802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=459802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=459802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}