Awesome code Brian. Just a few questions, Does the reg give it a memory and you can only shut off the pin afterwards when its declared as reg? I thought this was pure combination with a CPLD, and by nature the output doesnt need to be told otherwise if its set high. Or are you coding this in a FPGA oriented style?
I am just trying to understand the reasoning, I have not decided yet on wether I will go CPLD or FPGA.
Also, I have a few
bold questions.
module decode_24bits_2_pins (clk, pixel_in, pin_out_1, pin_out_2, pin_out_3, pin_out_4, ect...);
module decode_24bits_2_pins ?? Is this a pre-defined function, what are you telling here exactly? You seem to define the necessary I/O's for the logic, why is this necessary?? input clk;
input [23:0] pixel_in;
? output pin_out_1;
why is there such a big gap here, is this just your coding style and tabulation? output pin_out_2;
output pin_out_3;
output pin_out_4;
reg pin_out_1;
So a pin is defined as an output but as a reg also?? reg pin_out_2;
reg pin_out_3;
reg pin_out_4;
always@(posedge clk) begin
This functiions interacts with the input variable "clk" defined above and makes this pos edge? Simple as that? Awesome... if (pixel_in[23:0] == 'h000000) output_pin_1 <= 1; // turn on output pin 1 if black...
else if (pixel_in[23:0] == 'hFFFFFF) output_pin_1 <= 1; // or turn on output pin 1 if white...
else if (pixel_in[23:0] == 'h00FF00) output_pin_1 <= 1; // or turn on output pin 1 if green...
else if (pixel_in[23:0] == 'h00FE00) output_pin_1 <= 1; // or turn on output pin 1 if slightly darker green...
else output_pin_1 <= 0; // turn off output pin 1 under any other circumstance
if (pixel_in[23:0] == 'h808080) output_pin_2 <= 1; // turn on output pin 2 if gray...
else output_pin_2 <= 0; // turn off output pin 2 under any other circumstance
if (pixel_in[23:0] == 'h0000FF) output_pin_3 <= 0; // turn off output pin 3 if red...
else if (pixel_in[23:0] == 'h00FFFF) output_pin_3 <= 0; // or turn off output pin 3 if yellow...
else output_pin_3 <= 1; // turn on output pin 3 under any other circumstance
if (pixel_in[23:0] == 'h0000FF) output_pin_4 <= 1; // turn on output pin 4 if red...
else if (pixel_in[23:0] == 'hFF0000) output_pin_4 <= 1; // or turn on output pin 4 if blue...
else if (pixel_in[23:0] == 'h00FFFF) output_pin_4 <= 0; // or turn off output pin 4 if yellow...
else if (pixel_in[23:0] == 'h00FF00) output_pin_4 <= 0; // or turn off output pin 4 if green...
...... ect.......
end
endmodule