数字系统设计【夏宇闻】CPU代码,书中代码有几处的错误.docx

数字系统设计【夏宇闻】CPU代码,书中代码有几处的错误.docx

  1. 1、本文档共15页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数字系统设计【夏宇闻】CPU代码,书中代码有几处的错误

//adder counter用于存放当前结果,当累加器ena接口接受到cpu的load_acc信号时,保存数据总线数据 module accum( input clk, input rst, input [7:0]data, input ena, output reg [7:0]accum ); always @(posedge clk) begin if(rst) begin accum = 8b0000_0000; end else begin accum = data; end end endmodule //地址译码器 module addr_decode( input [12:0]addr, output reg rom_sel, output reg ram_sel ); always @(addr) begin casex(addr) 13b1_1xxx_xxxx_xxxx : {rom_sel,ram_sel} = 2b01; 13b0_xxxx_xxxx_xxxx : {rom_sel,ram_sel} = 2b10; 13b1_0xxx_xxxx_xxxx : {rom_sel,ram_sel} = 2b10; default {rom_sel,ram_sel} = 2b00; endcase end endmodule //地址多路器 module adr( input [12:0]pc_addr, input [12:0]ir_addr, input fetch, output [12:0]addr ); assign addr = (fetch) ? pc_addr : ir_addr; endmodule //算术运算器 module alu( input clk, input rst, input [7:0]data, input [7:0]accum, input [2:0]opcode, input alu_ena, output reg zero, output reg[7:0]alu_out); parameter HLT = 3b000, SKZ = 3b001, ADD = 3b010, ANDD = 3b011, XORR = 3b100, LDA = 3b101, STO = 3b110, JMP = 3b111; //此处有疑问,省略了assign zero = !accum; always @(posedge clk) begin if(alu_ena) begin case (opcode) HLT : alu_out = accum; SKZ : alu_out = accum; ADD : alu_out = data + accum; ANDD: alu_out = data accum; XORR: alu_out = data ^ accum; LDA : alu_out = data; STO : alu_out = accum; JMP : alu_out = accum; default : alu_out = 8bxxxx_xxxx; endcase end end endmodule //时钟产生器 module clk_gen( input clk, input reset, output reg fetch, output reg alu_ena ); reg [7:0]state; parameter S1 = 8b0000_0001, S2 = 8b0000_0010, S3 = 8b0000_0100,

文档评论(0)

shuwkb + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档