Cryptol_04_flow equation/synonym/class/module

Cryptol stream equation/synonym/class/module

Download learning reference materials: https://cryptol.net/documentation.html

Flow equation

  1. For the shift feedback register in the figure below, the description code is as follows:
    Insert picture description here

    as = [0x3F, 0xE2, 0x65, 0xCA] # new
    where
    new = [ a ^ b ^ c | a <- as
    | b <- drop`{
          
          1} as
    | c <- drop`{
          
          3} as ]
    

Synonym

  1. Similar to the definition of typedef in C language, but more powerful and can be parameterized;

    type Word8 = [8]
    type CheckedWord = (Word8, Bit)
    type Point a  = {
          
          x : [a], y : [a]}
    

Class//Class in Cpp is not a concept

  1. Used to describe the behavior shared by multiple types, such as == to compare any single type and return a Boolean value;

    Cryptol> :t (==)
    (==) : {
          
          a} (Eq a) => a -> a -> Bit
    

Program structure with module

  1. Similar to the concept of Verilog's module, a file can only have one module, and the module and the file name are the same;

  2. The first line of non-commented code in the file should be:

    module utilities where

  3. If you want to use other modules, you can use the following definitions, and the corresponding files will be searched in the current directory:

    import utilities

  4. Private variables, similar to Cpp, prevent the data of your own module from being accessed;

    private internalDouble x = x + x
    exportedDouble = x * 2
    

It's hard to understand by just looking at the description document, the next step is to look at it in conjunction with the code!

Guess you like

Origin blog.csdn.net/weixin_41754258/article/details/112132830