data/full_repos/permissive/425573648/fpga/lcd.v
data/verilator_xmls/e138a102-b8d6-45e7-b82b-b88fc091a1bc.xml
module lcd(
	input clk,
	input res,
	input [71:0]k_params,
	input [63:0]v_params,
	output reg lcd_rs,
	output lcd_rw,
	output lcd_en,
	output reg [7:0]lcd_data
);



parameter	INIT = 3'd0,
				LOAD = 3'd1,
				PUSH = 3'd2,
				IDLE = 3'd3;


reg [5:0] index;


reg [2:0]S;


always @(posedge clk or negedge res) 
	begin

		if (!res) 
			begin
				index <= 0;
				S <= INIT;
			end
		else 
			begin
				case (S)
					INIT: 
						begin

							index <= 0;
							S <= LOAD;
						end	
					LOAD: 
						begin
							if (index > 36)
								begin

									S <= IDLE;
								end
							else
								begin

									S <= PUSH;
								end							
						end
					PUSH: 
						begin

							index <= index + 1;
							S <= LOAD;
						end
					IDLE: 
						begin

							S <= IDLE;
						end
					default: 
						begin

							index <= 0;
							S <= INIT;
						end
				endcase
		end
	end


assign lcd_en = (S == PUSH);
assign lcd_rw = 0;
	
always @(*)
	begin
		case (index)
			0: {lcd_rs, lcd_data} = {1'b0, 8'b0011_1000};
			1: {lcd_rs, lcd_data} = {1'b0, 8'b0000_0110};
			2: {lcd_rs, lcd_data} = {1'b0, 8'b0000_0001};
										
			3: {lcd_rs, lcd_data} = {1'b1,  "K"};
			4: {lcd_rs, lcd_data} = {1'b1,  "p"};
			5: {lcd_rs, lcd_data} = {1'b1,  " "};
			6: {lcd_rs, lcd_data} = {1'b1,  " "};
			7: {lcd_rs, lcd_data} = {1'b1,  "K"};
			8: {lcd_rs, lcd_data} = {1'b1,  "i"};
			9: {lcd_rs, lcd_data} = {1'b1,  " "};
			10: {lcd_rs, lcd_data} = {1'b1,  " "};
			11: {lcd_rs, lcd_data} = {1'b1,  "K"};
			12: {lcd_rs, lcd_data} = {1'b1,  "d"};
			13: {lcd_rs, lcd_data} = {1'b1,  " "};
			14: {lcd_rs, lcd_data} = {1'b1,  " "};
			15: {lcd_rs, lcd_data} = {1'b1,  v_params[63:56]};
			16: {lcd_rs, lcd_data} = {1'b1,  v_params[55:48]};
			17: {lcd_rs, lcd_data} = {1'b1,  v_params[47:40]};
			18: {lcd_rs, lcd_data} = {1'b1,  v_params[39:32]};
	 
			19: {lcd_rs, lcd_data} = {1'b0, 8'b1100_0000};
		
			20: {lcd_rs, lcd_data} = {1'b1,  k_params[71:64]};
			21: {lcd_rs, lcd_data} = {1'b1,  k_params[63:56]};
			22: {lcd_rs, lcd_data} = {1'b1,  k_params[55:48]};
			23: {lcd_rs, lcd_data} = {1'b1,  " "};
			24: {lcd_rs, lcd_data} = {1'b1,  k_params[47:40]};
			25: {lcd_rs, lcd_data} = {1'b1,  k_params[39:32]};
			26: {lcd_rs, lcd_data} = {1'b1,  k_params[31:24]};
			27: {lcd_rs, lcd_data} = {1'b1,  " "};
			28: {lcd_rs, lcd_data} = {1'b1,  k_params[23:16]};
			29: {lcd_rs, lcd_data} = {1'b1,  k_params[15:8]};
			30: {lcd_rs, lcd_data} = {1'b1,  k_params[7:0]};
			31: {lcd_rs, lcd_data} = {1'b1,  " "};
			32: {lcd_rs, lcd_data} = {1'b1,  v_params[31:24]};
			33: {lcd_rs, lcd_data} = {1'b1,  v_params[23:16]};
			34: {lcd_rs, lcd_data} = {1'b1,  v_params[15:8]};
			35: {lcd_rs, lcd_data} = {1'b1,  v_params[7:0]};

			default: {lcd_rs, lcd_data} = {1'b0, 8'b1000_0000};
		endcase 
	end
endmodule
module lcd(
	input clk,
	input res,
	input [71:0]k_params,
	input [63:0]v_params,
	output reg lcd_rs,
	output lcd_rw,
	output lcd_en,
	output reg [7:0]lcd_data
);




parameter	INIT = 3'd0,
				LOAD = 3'd1,
				PUSH = 3'd2,
				IDLE = 3'd3;


reg [5:0] index;


reg [2:0]S;


always @(posedge clk or negedge res) 
	begin

		if (!res) 
			begin
				index <= 0;
				S <= INIT;
			end
		else 
			begin
				case (S)
					INIT: 
						begin

							index <= 0;
							S <= LOAD;
						end	
					LOAD: 
						begin
							if (index > 36)
								begin

									S <= IDLE;
								end
							else
								begin

									S <= PUSH;
								end							
						end
					PUSH: 
						begin

							index <= index + 1;
							S <= LOAD;
						end
					IDLE: 
						begin

							S <= IDLE;
						end
					default: 
						begin

							index <= 0;
							S <= INIT;
						end
				endcase
		end
	end


assign lcd_en = (S == PUSH);
assign lcd_rw = 0;
	
always @(*)
	begin
		case (index)
			0: {lcd_rs, lcd_data} = {1'b0, 8'b0011_1000};
			1: {lcd_rs, lcd_data} = {1'b0, 8'b0000_0110};
			2: {lcd_rs, lcd_data} = {1'b0, 8'b0000_0001};
										
			3: {lcd_rs, lcd_data} = {1'b1,  "K"};
			4: {lcd_rs, lcd_data} = {1'b1,  "p"};
			5: {lcd_rs, lcd_data} = {1'b1,  " "};
			6: {lcd_rs, lcd_data} = {1'b1,  " "};
			7: {lcd_rs, lcd_data} = {1'b1,  "K"};
			8: {lcd_rs, lcd_data} = {1'b1,  "i"};
			9: {lcd_rs, lcd_data} = {1'b1,  " "};
			10: {lcd_rs, lcd_data} = {1'b1,  " "};
			11: {lcd_rs, lcd_data} = {1'b1,  "K"};
			12: {lcd_rs, lcd_data} = {1'b1,  "d"};
			13: {lcd_rs, lcd_data} = {1'b1,  " "};
			14: {lcd_rs, lcd_data} = {1'b1,  " "};
			15: {lcd_rs, lcd_data} = {1'b1,  v_params[63:56]};
			16: {lcd_rs, lcd_data} = {1'b1,  v_params[55:48]};
			17: {lcd_rs, lcd_data} = {1'b1,  v_params[47:40]};
			18: {lcd_rs, lcd_data} = {1'b1,  v_params[39:32]};
	 
			19: {lcd_rs, lcd_data} = {1'b0, 8'b1100_0000};
		
			20: {lcd_rs, lcd_data} = {1'b1,  k_params[71:64]};
			21: {lcd_rs, lcd_data} = {1'b1,  k_params[63:56]};
			22: {lcd_rs, lcd_data} = {1'b1,  k_params[55:48]};
			23: {lcd_rs, lcd_data} = {1'b1,  " "};
			24: {lcd_rs, lcd_data} = {1'b1,  k_params[47:40]};
			25: {lcd_rs, lcd_data} = {1'b1,  k_params[39:32]};
			26: {lcd_rs, lcd_data} = {1'b1,  k_params[31:24]};
			27: {lcd_rs, lcd_data} = {1'b1,  " "};
			28: {lcd_rs, lcd_data} = {1'b1,  k_params[23:16]};
			29: {lcd_rs, lcd_data} = {1'b1,  k_params[15:8]};
			30: {lcd_rs, lcd_data} = {1'b1,  k_params[7:0]};
			31: {lcd_rs, lcd_data} = {1'b1,  " "};
			32: {lcd_rs, lcd_data} = {1'b1,  v_params[31:24]};
			33: {lcd_rs, lcd_data} = {1'b1,  v_params[23:16]};
			34: {lcd_rs, lcd_data} = {1'b1,  v_params[15:8]};
			35: {lcd_rs, lcd_data} = {1'b1,  v_params[7:0]};

			default: {lcd_rs, lcd_data} = {1'b0, 8'b1000_0000};
		endcase 
	end
endmodule