-- Generic declaration.
generic ( CHAN_SEL : integer range 1 to 2 := 1);

-- replace the mux with:
c1Sel: if (CHAN_SEL = 1) generate
			mux_data_selected <= Channel_1_registered_data;
	   end generate c1Sel;

c2Sel: if (CHAN_SEL = 2) generate
			mux_data_selected <= Channel_2_registered_data;
	   end generate c2Sel; 		
	   
	   
-- uart_led instantiation buffer		
OBuf_led_ix : for i in 0 to 7 generate
      OBUF_led_i : OBUF
      generic map (DRIVE => 12, IOSTANDARD => "DEFAULT", SLEW => "SLOW")
      port map (
         O => led_pins(i),     -- Buffer output (connect directly to top-level port)
         I => LED_o(i)         -- Buffer input 
      );
   end generate;
   
   
   
   
-- TestBench    
   -- loop through the entire message
	sendChars: for i in 1 to MESSAGE'length loop
								  
		-- break the string into characters
		-- convert the character into a std_logic_vector of 8 bit
		char_to_send     := MESSAGE(i);  -- convert char to slv8
		char_code        := character'pos(char_to_send);  -- char to int
		slv_char_to_send := std_logic_vector(to_unsigned(char_code,8)); 
		
		data_to_send <= slv_char_to_send;  
								 
		-- send the start bit, then the 8 data bits, then the stop bit
		data_out_serial   <= '0';        -- send start bit
		wait for BIT_PERIOD;             -- and hold for one bit period   
												
	  
		-- loop through the 8 bits of data and send lsb first
		for j in 0 to 7 loop             -- loop through all 8 bits
			data_out_serial <= slv_char_to_send(j);      -- get the i-th bit from the character to send
			wait for BIT_PERIOD;                         -- and hold for one bit period
		end loop;                 
					  
		data_out_serial <= '1';                         -- send stop bit
		wait for BIT_PERIOD;                            -- delay a period 
									 
		data_sent   <= '1';                             -- this xmit done
		wait for 10 ns;                                 -- trigger validator
		data_sent <= '0';                             	-- drop the data sent
		wait for BIT_PERIOD*5;                          -- idle 5 bit periods
												  
	end loop; -- sendChars
		
		
		
		
