cg.v 1.06 KB
// $Id: cg.v,v 1.1.1.1 2002/05/17 06:14:58 blythe Exp $

`timescale 1ns/100ps

module cg(clock, reset_l, bus_clk, vbus_clock);

`include "reality.vh"
`include "define.vh"

parameter RAMBUS_CLOCK_PERIOD	= 4.0;  // 250 MHz Rambus

input reset_l;
input clock;
output bus_clk;
output vbus_clock;


reg bus_clk;
reg vbus_clock;
integer clock_count;

initial bus_clk = HIGH;

// freeze vclk flag
reg freeze_vclk;
initial freeze_vclk = LOW;

reg tssi_capture;

initial
begin

  tssi_capture = 0;

  if ($test$plusargs("rcp_test_tssi") || $test$plusargs("rcp_full_tssi") ||
      $test$plusargs("rcp_attest_tab") || $test$plusargs("rcp_hp330_tssi"))

   begin
    tssi_capture = 1;
    vbus_clock = LOW;
   end
  else
    vbus_clock = HIGH;
end

always #(RAMBUS_CLOCK_PERIOD / 2) bus_clk = ~bus_clk;

always #(RAMBUS_CLOCK_PERIOD * 2)
begin
  if (tssi_capture)
    vbus_clock = ~vbus_clock || freeze_vclk;
end

always #((RAMBUS_CLOCK_PERIOD * 5 )/ 2)
begin
  if (!tssi_capture)
    vbus_clock = ~vbus_clock;
end

always @(posedge clock) clock_count <= reset_l ? clock_count + 1 : 0;

endmodule