from docutils import nodes
from sphinx.util.compat import Directive, make_admonition
DANGER_MESSAGE = """
This is a "Hazardous Materials" module. You should **ONLY** use it if you're
100% absolutely sure that you know what you're doing because this module is
full of land mines, dragons, and dinosaurs with laser guns. """
class HazmatDirective(Directive):
def run(self):
ad = make_admonition(
Hazmat,
self.name,
[],
self.options,
nodes.paragraph("", DANGER_MESSAGE),
self.lineno,
self.content_offset,
self.block_text,
self.state,
self.state_machine
)
ad[0].line = self.lineno
return ad
class Hazmat(nodes.Admonition, nodes.Element):
pass
def html_visit_hazmat_node(self, node):
return self.visit_admonition(node, "danger")
def latex_visit_hazmat_node(self, node):
return self.visit_admonition(node)
def depart_hazmat_node(self, node):
return self.depart_admonition(node)
def setup(app):
app.add_node(
Hazmat,
html=(html_visit_hazmat_node, depart_hazmat_node),
latex=(latex_visit_hazmat_node, depart_hazmat_node),
)
app.add_directive("hazmat", HazmatDirective)
s/about/'>aboutsummaryrefslogtreecommitdiffstats
|
blob: 23f0da04b1ebcd7446caedea36144b4711a0a646 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
//==========================================
// Function : Code Gray counter.
// Coder : Alex Claros F.
// Date : 15/May/2005.
//=======================================
module GrayCounter
#(parameter COUNTER_WIDTH = 4)
(output reg [COUNTER_WIDTH-1:0] GrayCount_out, //'Gray' code count output.
input wire Enable_in, //Count enable.
input wire Clear_in, //Count reset.
input wire Clk);
/////////Internal connections & variables///////
reg [COUNTER_WIDTH-1:0] BinaryCount;
/////////Code///////////////////////
always @ (posedge Clk)
if (Clear_in) begin
BinaryCount <= {COUNTER_WIDTH{1'b 0}} + 1; //Gray count begins @ '1' with
GrayCount_out <= {COUNTER_WIDTH{1'b 0}}; // first 'Enable_in'.
end
else if (Enable_in) begin
BinaryCount <= BinaryCount + 1;
GrayCount_out <= {BinaryCount[COUNTER_WIDTH-1],
BinaryCount[COUNTER_WIDTH-2:0] ^ BinaryCount[COUNTER_WIDTH-1:1]};
end
endmodule
|