pc_rom代码及其仿真

module inst_fetch(input wire clk,input wire rst,output wire[31:0] inst_o);
wire[5:0] pc;wire rom_ce;
pc_reg pc_reg0(.clk(clk),.rst(rst),.ce(rom_ce),.pc(pc));
rom rom0(.addr(pc),.ce(rom_ce),.inst(inst_o));
endmodule 
module pc_reg(               input wire rst,               input wire clk,               output reg[5:0] pc,               output reg ce);
always @(posedge clk)begin   if (rst==1'b1)   begin   ce<=1'b0;   end   else   begin   ce<=1'b1;   endend
always @(posedge clk)begin    if (ce==1'b0)    begin     pc<=6'h00;    end    else    begin    pc<=pc+1'b1;    endend 
endmodule 
module rom(input wire[5:0] addr,input wire ce,output reg[31:0] inst);
reg[31:0] rom[63:0];
initial $readmemh ("D:/chengxu/yingjian/pc_rom/rom.data",rom);
always @(*)begin    if (ce == 1'b0)    begin    inst <= 32'h0;    end    else    begin    inst<= rom[addr];    endend
endmodule 
module inst_fetch_tb;
reg CLOCK;reg rst;wire[31:0] inst;
initialbeginCLOCK = 1'b0;forever #10 CLOCK =~CLOCK;end
initial begin rst =1'b1;#195 rst =1'b0;#1000 $stop;end
inst_fetch inst_fetch0(.clk(CLOCK),.rst(rst),.inst_o(inst));
endmodule


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值