<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://old.hacdc.org/index.php?action=history&amp;feed=atom&amp;title=FPGAExercise8code</id>
	<title>FPGAExercise8code - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://old.hacdc.org/index.php?action=history&amp;feed=atom&amp;title=FPGAExercise8code"/>
	<link rel="alternate" type="text/html" href="https://old.hacdc.org/index.php?title=FPGAExercise8code&amp;action=history"/>
	<updated>2026-05-07T14:53:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://old.hacdc.org/index.php?title=FPGAExercise8code&amp;diff=10393&amp;oldid=prev</id>
		<title>Haxwithaxe: /* Level-to-pulser */</title>
		<link rel="alternate" type="text/html" href="https://old.hacdc.org/index.php?title=FPGAExercise8code&amp;diff=10393&amp;oldid=prev"/>
		<updated>2014-03-31T16:06:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Level-to-pulser&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:06, 31 March 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l59&quot;&gt;Line 59:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 59:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;endmodule  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;endmodule  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Level-to-pulser Testbench ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Level-to-pulser Testbench ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Haxwithaxe</name></author>
	</entry>
	<entry>
		<id>https://old.hacdc.org/index.php?title=FPGAExercise8code&amp;diff=2565&amp;oldid=prev</id>
		<title>Williamgibb at 10:01, 7 December 2009</title>
		<link rel="alternate" type="text/html" href="https://old.hacdc.org/index.php?title=FPGAExercise8code&amp;diff=2565&amp;oldid=prev"/>
		<updated>2009-12-07T10:01:35Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:01, 7 December 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l145&quot;&gt;Line 145:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 145:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:FPGAWorkshop]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Williamgibb</name></author>
	</entry>
	<entry>
		<id>https://old.hacdc.org/index.php?title=FPGAExercise8code&amp;diff=2564&amp;oldid=prev</id>
		<title>66.92.147.234: Created page with &#039;== Level-to-pulser ==  Finite state machine implementation of a device that takes a level change (low to high) and turns it into a one-period pulse.    &lt;pre&gt; module levelToPulse(…&#039;</title>
		<link rel="alternate" type="text/html" href="https://old.hacdc.org/index.php?title=FPGAExercise8code&amp;diff=2564&amp;oldid=prev"/>
		<updated>2009-12-07T04:01:59Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;== Level-to-pulser ==  Finite state machine implementation of a device that takes a level change (low to high) and turns it into a one-period pulse.    &amp;lt;pre&amp;gt; module levelToPulse(…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Level-to-pulser ==&lt;br /&gt;
&lt;br /&gt;
Finite state machine implementation of a device that takes a level change (low to high) and turns it into a one-period pulse.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module levelToPulse(clk, in, out, reset);&lt;br /&gt;
   &lt;br /&gt;
   input  clk, in, reset;&lt;br /&gt;
   output reg out;&lt;br /&gt;
   reg  [1:0]  state, next;&lt;br /&gt;
&lt;br /&gt;
   // States&lt;br /&gt;
   parameter WAIT_LOW = 0; &lt;br /&gt;
   parameter WAIT_HIGH = 1;&lt;br /&gt;
   parameter RISING = 2; // I&amp;#039;ve just seen a rising edge&lt;br /&gt;
   parameter PULSE = 3; // I&amp;#039;m in the process of generating a pulse&lt;br /&gt;
&lt;br /&gt;
   // Reset or update the state on every clock&lt;br /&gt;
   always @ (posedge clk or reset) &lt;br /&gt;
     begin&lt;br /&gt;
        if (reset)&lt;br /&gt;
          begin&lt;br /&gt;
             state &amp;lt;= WAIT_LOW;&lt;br /&gt;
             next &amp;lt;= WAIT_LOW;&lt;br /&gt;
             out = 0;&lt;br /&gt;
          end&lt;br /&gt;
        else&lt;br /&gt;
          state &amp;lt;= next;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
   // What to do in each state&lt;br /&gt;
   always @ (state or in) begin &lt;br /&gt;
      case (state)                       &lt;br /&gt;
        WAIT_LOW:&lt;br /&gt;
          begin&lt;br /&gt;
             if (in == 1) &lt;br /&gt;
               next = RISING;&lt;br /&gt;
          end&lt;br /&gt;
        RISING:&lt;br /&gt;
          begin&lt;br /&gt;
             out = 1; &lt;br /&gt;
             next = PULSE;&lt;br /&gt;
          end&lt;br /&gt;
        PULSE:&lt;br /&gt;
          begin&lt;br /&gt;
             out = 0;&lt;br /&gt;
             if (in == 0) &lt;br /&gt;
               next = WAIT_LOW;&lt;br /&gt;
             else&lt;br /&gt;
               next = WAIT_HIGH;&lt;br /&gt;
          end&lt;br /&gt;
        WAIT_HIGH:&lt;br /&gt;
          if (in == 0)&lt;br /&gt;
            next = WAIT_LOW;&lt;br /&gt;
      endcase // case (state)&lt;br /&gt;
&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
endmodule &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Level-to-pulser Testbench ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module test_stateMachine();&lt;br /&gt;
   // Parameters&lt;br /&gt;
   parameter CLKPERIOD  = 20;   // 50MHz at 1ns&lt;br /&gt;
   parameter FINISHTIME = 1000; // 1ms&lt;br /&gt;
   &lt;br /&gt;
   // DUT inputs&lt;br /&gt;
&lt;br /&gt;
   reg clk, in, reset;&lt;br /&gt;
   &lt;br /&gt;
   // DUT outputs&lt;br /&gt;
   wire out;&lt;br /&gt;
      &lt;br /&gt;
   // DUT instantiation&lt;br /&gt;
   // &lt;br /&gt;
   levelToPulse DUT(clk, in, out, reset);&lt;br /&gt;
       &lt;br /&gt;
   // Stimulus&lt;br /&gt;
&lt;br /&gt;
   // Clock generation&lt;br /&gt;
   always&lt;br /&gt;
     #(CLKPERIOD/2) clk = ~clk;&lt;br /&gt;
&lt;br /&gt;
   // Initial conditions&lt;br /&gt;
   initial&lt;br /&gt;
     begin&lt;br /&gt;
        in = 0;&lt;br /&gt;
        clk = 1;&lt;br /&gt;
        reset = 0;&lt;br /&gt;
        // When at finishtime -- this shouldn&amp;#039;t happen.  It&amp;#039;s just a safety.&lt;br /&gt;
        #FINISHTIME $display (&amp;quot;Reached the end of the sidewalk: %5d&amp;quot;, $time);&lt;br /&gt;
        $finish;        &lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
   // Inputs&lt;br /&gt;
   initial&lt;br /&gt;
     begin&lt;br /&gt;
&lt;br /&gt;
        //  Reset and wait&lt;br /&gt;
        #3 reset = 1; &lt;br /&gt;
        #3 reset = 0;&lt;br /&gt;
&lt;br /&gt;
        repeat(5)&lt;br /&gt;
          #CLKPERIOD;&lt;br /&gt;
&lt;br /&gt;
        // Go level high&lt;br /&gt;
        in = 1;&lt;br /&gt;
        repeat(5)&lt;br /&gt;
          #CLKPERIOD;&lt;br /&gt;
&lt;br /&gt;
        // Go low&lt;br /&gt;
        in = 0;&lt;br /&gt;
        repeat(4)&lt;br /&gt;
          #CLKPERIOD;&lt;br /&gt;
&lt;br /&gt;
        // Delay a short time so that input is in different phase with the clock&lt;br /&gt;
        #(CLKPERIOD / 2);&lt;br /&gt;
        &lt;br /&gt;
        in = 1;&lt;br /&gt;
        repeat(5)&lt;br /&gt;
          #CLKPERIOD;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        $display(&amp;quot;-----------------------&amp;quot;);&lt;br /&gt;
        $display(&amp;quot;- Normal End at %5t -&amp;quot;, $time);&lt;br /&gt;
        $display(&amp;quot;-----------------------&amp;quot;);&lt;br /&gt;
        $finish;&lt;br /&gt;
        &lt;br /&gt;
        &lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   // Monitor&lt;br /&gt;
   initial&lt;br /&gt;
     begin&lt;br /&gt;
        $dumpfile (&amp;quot;test_stateMachine.lxt&amp;quot;);&lt;br /&gt;
        $dumpvars(0, test_stateMachine); &lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
endmodule &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>66.92.147.234</name></author>
	</entry>
</feed>