#!/usr/bin/env ruby


template = <<'END'
		-- (tv #1342) read output FIFO
		(
			cycles		=>	1,
			cm_i		=>	bus_read_init(addr => ADDR_KS_OFIFO_DOUT),
			sep			=>	msg(""),
			cm_o 		=>	bus_no_ack,
			irq			=>	(others => '0')
		),

		-- (tv #1343) wait while FIFO is read
		(
			cycles		=>	2,
			cm_i		=>	bus_wait_ack,
			sep			=>	msg(""),
			cm_o 		=>	bus_no_ack,
			irq			=>	(others => '0')
		),

		-- (tv #1343) wait for ack
		(
			cycles		=>	1,
			cm_i		=>	bus_wait_ack,
			sep			=>	msg(""),
			cm_o 		=>	bus_read_ack(dat => #{exp_data}),
			irq			=>	(others => '0')
		),

END

puts "KS-128 testvectors:\n"
puts "\n" * 3


0.upto(10) { |sk_no|
	3.downto(0) { |sl_no|
		exp_data = "slice_32(TC1_SUBKEYS(#{sk_no}), #{sl_no})"
		t = template.gsub(/"/, '\\"')
		puts eval("format(\"#{t}\")")
	}
}
