F
filippo
Guest
I' m having great troubles making a small project on FPGA in Verilog.
I have to do it for an exam at university, it shoul be simple but it's
becoming hell.
facts:
- FPGA SPARTAN II xc2s100-5pq208
- Xilinx webpack ISE + modelsim
- uP: AVRmega163
problem:
all simulations with modelsim are good, but it just doesn' t work on
the real FPGA and i don't know where to find a solution (or where is
the real problem).
of the 10+ modules one seems to be the most troublesome, our
IO_control, here is the code ,please help.
---------------------------------------------------------------------------------
module IO_control(ALE,NWR,NRD,DIR,DA,MIN,MAX,SEL,TYPEFIL,AMPLIF,DIVFRQ,clk);
input ALE;
input NWR;
input clk;
input NRD;
input DIR;
input [7:0] MIN;
input [7:0] MAX;
inout [7:0] DA;
output [7:0] SEL;
output [7:0] TYPEFIL;
output [7:0] AMPLIF;
output [7:0] DIVFRQ;
parameter uno = 8'b0000_0001;
reg [7:0] ADDR_REG;
reg [7:0] DO_REG;
reg [7:0] SEL_REG=uno;
reg [7:0] TYPEFIL_REG=uno;
reg [7:0] AMPLIF_REG=uno;
reg [7:0] DIVFRQ_REG=uno;
assign SEL = SEL_REG;
assign TYPEFIL = TYPEFIL_REG;
assign AMPLIF = AMPLIF_REG;
assign DIVFRQ = DIVFRQ_REG;
assign DA = (DIR) ? 8'bzzzz_zzzz : DO_REG;
always @ (posedge clk)
begin
if (ALE) ADDR_REG <= DA;
if (~NWR)
case (ADDR_REG)
8'b0000_0001 : SEL_REG <= DA;
8'b0000_0010 : TYPEFIL_REG <= DA;
8'b0000_0100 : AMPLIF_REG <= DA;
8'b0000_1000 : DIVFRQ_REG <=DA;
default DO_REG <= 8'b1111_1111;
endcase
if (~NRD)
case (ADDR_REG)
8'b0000_0001 : DO_REG <= SEL_REG;
8'b0000_0010 : DO_REG <= TYPEFIL_REG;
8'b0000_0100 : DO_REG <= AMPLIF_REG;
8'b0000_1000 : DO_REG <= DIVFRQ_REG;
8'b0001_0000 : DO_REG <= MIN;
8'b0010_0000 : DO_REG <= MAX;
default DO_REG <= 8'b1111_1111;
endcase
end
endmodule
I have to do it for an exam at university, it shoul be simple but it's
becoming hell.
facts:
- FPGA SPARTAN II xc2s100-5pq208
- Xilinx webpack ISE + modelsim
- uP: AVRmega163
problem:
all simulations with modelsim are good, but it just doesn' t work on
the real FPGA and i don't know where to find a solution (or where is
the real problem).
of the 10+ modules one seems to be the most troublesome, our
IO_control, here is the code ,please help.
---------------------------------------------------------------------------------
module IO_control(ALE,NWR,NRD,DIR,DA,MIN,MAX,SEL,TYPEFIL,AMPLIF,DIVFRQ,clk);
input ALE;
input NWR;
input clk;
input NRD;
input DIR;
input [7:0] MIN;
input [7:0] MAX;
inout [7:0] DA;
output [7:0] SEL;
output [7:0] TYPEFIL;
output [7:0] AMPLIF;
output [7:0] DIVFRQ;
parameter uno = 8'b0000_0001;
reg [7:0] ADDR_REG;
reg [7:0] DO_REG;
reg [7:0] SEL_REG=uno;
reg [7:0] TYPEFIL_REG=uno;
reg [7:0] AMPLIF_REG=uno;
reg [7:0] DIVFRQ_REG=uno;
assign SEL = SEL_REG;
assign TYPEFIL = TYPEFIL_REG;
assign AMPLIF = AMPLIF_REG;
assign DIVFRQ = DIVFRQ_REG;
assign DA = (DIR) ? 8'bzzzz_zzzz : DO_REG;
always @ (posedge clk)
begin
if (ALE) ADDR_REG <= DA;
if (~NWR)
case (ADDR_REG)
8'b0000_0001 : SEL_REG <= DA;
8'b0000_0010 : TYPEFIL_REG <= DA;
8'b0000_0100 : AMPLIF_REG <= DA;
8'b0000_1000 : DIVFRQ_REG <=DA;
default DO_REG <= 8'b1111_1111;
endcase
if (~NRD)
case (ADDR_REG)
8'b0000_0001 : DO_REG <= SEL_REG;
8'b0000_0010 : DO_REG <= TYPEFIL_REG;
8'b0000_0100 : DO_REG <= AMPLIF_REG;
8'b0000_1000 : DO_REG <= DIVFRQ_REG;
8'b0001_0000 : DO_REG <= MIN;
8'b0010_0000 : DO_REG <= MAX;
default DO_REG <= 8'b1111_1111;
endcase
end
endmodule