Forum Discussion
Altera_Forum
Honored Contributor
8 years agoyou are right this are a little part of the code with coments
module video_controller (
input clock ,
input start , //not used per now
input color_in, //not used per now
input x, //not used per now
input y, //not used per now
input h, //not used per now
input w, //not used per now
output reg data,
output reg latches,
output finish, //not used per now
output color_in_next, //not used per now
output reg rst
);
reg i_counter=0; //start i_counter=0
localparam StartCmd=4'b0101;
localparam EndCmd=4'b1111;
localparam StartIdx=4'b0100;
localparam EndIdx=4'b1110;
reg init = 1'b1; //variable to start sequencial
always@(posedge clock && init)
begin
i_counter<=i_counter+1; //increment on posedge clock
//data 8 bits of data bus to external device
//latches are the clock,cs,write and read this ar params of the external device
case (i_counter)
10 :rst=1'b0; //1 step - reset device
1000 :rst=1'b1; //2 step - reset device
1010 :latches=StartIdx; //3 step - latches = 0100
1020 :data=8'h01; //4 step - send to device = h01
1030 :latches=EndIdx; //5 step - latches = 1110 & WAIT of 1000
2000 :latches=StartIdx; //3 step - latches = 0100
2010 :data=8'h01; //4 step - send to device = h01
2020 :latches=EndIdx; //5 step - latches = 1110 & WAIT of 1000
3000 :latches=StartIdx; //3 step - latches = 0100
3010 :data=8'h01; //4 step - send to device = h01
3020 :latches=EndIdx; //5 step - latches = 1110
4000 :latches=StartIdx; //3 step - latches = 0100
4010 :data=8'he0; //4 step - send to device = he0
4020 :latches=EndIdx; //5 step - latches = 1110 & WAIT of 1000
5000 :latches=StartCmd; //3 step - latches = 0101
5010 :data=8'h01; //4 step - send to device = h01
5020 :latches=EndCmd; //5 step - latches = 1111 & WAIT of 1000
6000 :latches=StartIdx; //3 step - latches = 0100
6010 :data=8'he0; //4 step - send to device = he0
6020 :latches=EndIdx; //5 step - latches = 1110
6030 :latches=StartCmd; //3 step - latches = 0101
6040 :data=8'h03; //4 step - send to device = h03
6050 :latches=EndCmd; //5 step - latches = 1111
One big case statement why?. Because i need a sequential and timming excecution on ports Best Regards