|
module register(opc_iraddr,data,ena,clk1,rst);
3 output [15:0] opc_iraddr;
4 input [7:0] data;
5 input ena, clk1, rst;
6 reg [15:0] opc_iraddr;
7 reg state;
8
9 always @(posedge clk1)
10 begin
11 if(rst)
12 begin
13 opc_iraddr<=16'b0000_0000_0000_0000;
14 state<=1'b0;
15 end
16 else
17 begin
18 if(ena) //如果加载指令寄存器信号load_ir到来,
19 begin //分两个时钟每次8位加载指令寄存器
20 casex(state) //先高字节,后低字节
21 1’b0: begin
22 opc_iraddr[15:8]<=data;
23 state<=1;
24 end
25 1’b1: begin
26 opc_iraddr[7:0]<=data;
27 state<=0;
28 end
29 default: begin
30 opc_iraddr[15:0]<=16'bxxxxxxxxxxxxxxxx;
31 state<=1'bx;
32 end
33 endcase
34 end
35 else
36 state<=1'b0;
37 end
38 end
39 endmodule |
|