// rst reset
// clk clock
// pc_out output, connected to rom_addr_sel1, it's current rom addres
// alu input from alu, used in case of jumps (next addres is calculated in alu and written to pc)
// pc_wr_sel input indicates which input will be written to pc in case of writting
// op1 instruction (byte 1) used to calculate next addres
// op2 instruction (byte 2) used in jumps
// op3 instruction (byte 3) used in jumps
// wr write (active high)
// write_x output//**
// rd read: if high calculate next addres else hold current
// int interrupt (if high don't change outputs -- write to stack)
//
//pc program counter register, save current value
reg [15:0] pc;
//
// wr_lo write low: used in reti instruction, write only low byte of pc
// ini_buff interrupt buffer: used to prevent interrupting in the middle of executin instructions
reg wr_lo, int_buff;
always @(pc or op1 or rst or rd)
begin
if (rst) begin
//
// in cae of reset read value from buffer
pc_out= pc;
end else begin
if (int_buff)
//
//in case of interrupt hold valut, to be written to stack
pc_out= pc;
else if (rd) begin
//
// normal execution calculate next value and send it immediate to outputs
casex (op1)
`ACALL : pc_out= pc+2;
`AJMP : pc_out= pc+2;
always @(posedge clk)
begin
if (rst)
pc <= #1 `RST_PC;
else if (wr_lo)
pc[7:0] <= #1 alu[15:8];
else begin
if (wr) begin
//
//case of writing new value to pc (jupms)
case (pc_wr_sel)
`PIS_SP: begin
pc[15:8] <= #1 alu[15:8];
wr_lo <= #1 1'b1;
end
`PIS_ALU: pc <= #1 alu;
`PIS_I11: pc[10:0] <= #1 {op1[7:5], op2};
`PIS_I16: pc <= #1 {op2, op3};
endcase
end else
//
//or just remember current
pc <= #1 pc_out;
end
end
endmodule
错误:
Error (10028): Can't resolve multiple constant drivers for net "wr_lo" at pc.v(147)
Error (10029): Constant driver at pc.v(177)
Error: Can't elaborate top-level user hierarchy
就是说always @(posedge clk)
if (wr_lo) wr_lo <= #1 1'b0;错了