Port_ID随机变化,有时外向输出会提供内向数据。

时间:2018-06-27 13:40:22

标签: assembly verilog fpga picoblaze

我尝试用picoblaze做加法器,但是遇到了一些问题。

这是我的picoblaze代码:

LOAD s1,00
LOAD s0,00

start:
INPUT s0,00
ADD s1,s0
OUTPUT s1,01
JUMP start

然后我将这些代码与kcpsm3一起放在verilog上,并编写了顶层模块和一些代码:

    module top_module(
   input clock,
   input reset
   );



 integer i;
 wire [7:0] out_port;
 wire [9:0] address;
 wire [17:0] instruction;
 wire [7:0] port_id;
 wire write_strobe;
 wire read_strobe;
 reg [7:0] in_port;     
 wire interrupt;
 wire interrupt_ack;



 reg [7:0] counter ; 


 pico2 picoblaze2_asm (
.address(address), 
.instruction(instruction), 
.proc_reset(proc_reset), 
.clk(clock)
);

 kcpsm3 picoblaze2 (
.address(address), 
.instruction(instruction), 
.port_id(port_id), 
.write_strobe(write_strobe), 
.out_port(out_port), 
.read_strobe(read_strobe), 
.in_port(in_port), 
.interrupt(interrupt), 
.interrupt_ack(interrupt_ack), 
.reset(reset), 
.clk(clock)
);


 initial begin
 counter = 0;
 i = 0;
 end

 always @ (posedge clock)
 begin


 counter = counter+1;

 if(counter == 8)
 begin

 i = i+1;

  in_port = i;

 counter = 0;

 if(i == 10)
 begin
 i = 0;
 end


 end

 end




endmodule

这是我们的测试平台:

enter image description here

port_id接受0,1,2和一些输入数据,例如3,4,5,但是由于picoblaze汇编代码,我们希望接受0和1。 其次,out_port获取附加值(inport = 1,2 outport = 1 + 2 = 3)和一些输入数据3,4,5 我们只想获取增加的价值而没有引入价值。

赞:

*inport 1   2    3   4   5   6
*outport 1  3    6   10  15  21
*port id 0 1 0 1 0 1 0 1 0 1.....  

0 个答案:

没有答案